package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.product.BaseSaleAttr;
import com.atguigu.gmall.model.product.SpuSaleAttr;
import com.atguigu.gmall.product.service.BaseSaleAttrService;
import com.atguigu.gmall.product.service.SpuSaleAttrService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author A
 * @version 1.0
 * @description: TODO
 * @date 2025/8/28 1:25
 */
@RestController
@RequestMapping("/admin/product")
public class SaleAttrController {

    @Autowired
    private BaseSaleAttrService baseSaleAttrService;
    @Autowired
    private SpuSaleAttrService spuSaleAttrService;
    //获取销售属性列表
    @GetMapping("/baseSaleAttrList")
    public Result baseSaleAttrList(){
        List<BaseSaleAttr> baseSaleAttrList = baseSaleAttrService.list();
        return Result.ok(baseSaleAttrList);
    }
    //根据spuId获取销售属性
    @GetMapping("/spuSaleAttrList/{spuId}")
    public Result spuSaleAttrList(@PathVariable("spuId") Long spuId){

        return Result.ok(spuSaleAttrService.getSpuSaleAttrList(spuId));
    }
}
